﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.DynamicData;
using Infrastructure.Aspect.DynamicData.Fields;
namespace Skynet.DynamicSite.DynamicData.FieldTemplates
{
    public partial class Guid_InsertField : System.Web.DynamicData.FieldTemplateUserControl
    {

        

        protected void Page_Init(object sender, EventArgs e)
        {
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var autoGenerateField = MetadataAttributes.OfType<AutoGenerateField>().FirstOrDefault();
                if (autoGenerateField != null)
                {
                    if (autoGenerateField.Generate == true)
                    {
                        this.txtguid.Text = Guid.NewGuid().ToString();
                        this.txtguid.ReadOnly = true;
                    }
                }
            }

        }
        protected override void ExtractValues(System.Collections.Specialized.IOrderedDictionary dictionary)
        {
            dictionary[Column.Name] = ConvertEditedValue(this.txtguid.Text);
        }
            
    }
}